<!-- 送回-其他信息 -->

<template>
	<Card>
		<template #head>
			其他信息
		</template>
		<template #body>
			<CellItemDetail label="发票类型" :value="invoiceInfo.invoiceTypeToName"></CellItemDetail>
			<CellItemDetail label="发票号" :value="invoiceInfo.invoiceNum"></CellItemDetail>
			<CellItemDetail label="测试报告" :value="Number(invoiceInfo.testReportFlag) ? '是':'否'"></CellItemDetail>
			<CellItemDetail label="质保期" :value="invoiceInfo.warrantyPeriod" unit="个月"></CellItemDetail>
			<CellItemDetail label="质保开始" :value="invoiceInfo.warrantyStartTime"></CellItemDetail>
			<CellItemDetail label="附件" :value="Attachments" type="attachment"></CellItemDetail>

		</template>
	</Card>
</template>

<script>
	import Card from '@/components/card/components/cardDetail.vue'
	import CellItemDetail from '@/components/cell/itemDetail.vue'

	function toAttchmentFormat(val) {
		let value = []
		if (val == '[]' || val == "[]" || val) {
			value = JSON.parse(val)
		} else if (val == '' || val == "") {
			value = []
		} else {
			value = []
		}
		return value

	}
	export default {
		props: {
			invoiceInfo: {
				type: Object,
				default: () => {
					return {}
				}
			}
		},
		components: {
			Card,
			CellItemDetail
		},
		computed: {
			Attachments() {
				let { enclosure, invoiceEnclosure, testReportEnclosure } = this.invoiceInfo
				enclosure = toAttchmentFormat(enclosure)
				invoiceEnclosure = toAttchmentFormat(invoiceEnclosure)
				testReportEnclosure = toAttchmentFormat(testReportEnclosure)

				let arr = [...enclosure, ...invoiceEnclosure, ...testReportEnclosure]
				console.log(arr, '--------arr--------');
				return JSON.stringify(arr)
			}
		}
	}
</script>

<style lang="scss" scoped>

</style>
